//go:build windows

package windows

/*
#include "DirectX11.h"
*/
import "C"

type HResultError C.HRESULT

const (
	S_OK           = HResultError(C.S_OK)
	E_ABORT        = HResultError(C.E_ABORT)
	E_ACCESSDENIED = HResultError(C.E_ACCESSDENIED)
	E_FAIL         = HResultError(C.E_FAIL)
	E_HANDLE       = HResultError(C.E_HANDLE)
	E_INVALIDARG   = HResultError(C.E_INVALIDARG)
	E_NOINTERFACE  = HResultError(C.E_NOINTERFACE)
	E_NOTIMPL      = HResultError(C.E_NOTIMPL)
	E_OUTOFMEMORY  = HResultError(C.E_OUTOFMEMORY)
	E_POINTER      = HResultError(C.E_POINTER)
	E_UNEXPECTED   = HResultError(C.E_UNEXPECTED)

	DXGI_ERROR_ACCESS_DENIED = HResultError(C.DXGI_ERROR_ACCESS_DENIED)
	DXGI_ERROR_ACCESS_LOST   = HResultError(C.DXGI_ERROR_ACCESS_LOST)
	//DXGI_ERROR_ALREADY_EXISTS               = HResultError(C.DXGI_ERROR_ALREADY_EXISTS)
	DXGI_ERROR_CANNOT_PROTECT_CONTENT       = HResultError(C.DXGI_ERROR_CANNOT_PROTECT_CONTENT)
	DXGI_ERROR_DEVICE_HUNG                  = HResultError(C.DXGI_ERROR_DEVICE_HUNG)
	DXGI_ERROR_DEVICE_REMOVED               = HResultError(C.DXGI_ERROR_DEVICE_REMOVED)
	DXGI_ERROR_DEVICE_RESET                 = HResultError(C.DXGI_ERROR_DEVICE_RESET)
	DXGI_ERROR_DRIVER_INTERNAL_ERROR        = HResultError(C.DXGI_ERROR_DRIVER_INTERNAL_ERROR)
	DXGI_ERROR_FRAME_STATISTICS_DISJOINT    = HResultError(C.DXGI_ERROR_FRAME_STATISTICS_DISJOINT)
	DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE = HResultError(C.DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE)
	DXGI_ERROR_INVALID_CALL                 = HResultError(C.DXGI_ERROR_INVALID_CALL)
	DXGI_ERROR_MORE_DATA                    = HResultError(C.DXGI_ERROR_MORE_DATA)
	DXGI_ERROR_NAME_ALREADY_EXISTS          = HResultError(C.DXGI_ERROR_NAME_ALREADY_EXISTS)
	DXGI_ERROR_NONEXCLUSIVE                 = HResultError(C.DXGI_ERROR_NONEXCLUSIVE)
	DXGI_ERROR_NOT_CURRENTLY_AVAILABLE      = HResultError(C.DXGI_ERROR_NOT_CURRENTLY_AVAILABLE)
	DXGI_ERROR_NOT_FOUND                    = HResultError(C.DXGI_ERROR_NOT_FOUND)
	DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED   = HResultError(C.DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED)
	DXGI_ERROR_REMOTE_OUTOFMEMORY           = HResultError(C.DXGI_ERROR_REMOTE_OUTOFMEMORY)
	DXGI_ERROR_RESTRICT_TO_OUTPUT_STALE     = HResultError(C.DXGI_ERROR_RESTRICT_TO_OUTPUT_STALE)
	DXGI_ERROR_SDK_COMPONENT_MISSING        = HResultError(C.DXGI_ERROR_SDK_COMPONENT_MISSING)
	DXGI_ERROR_SESSION_DISCONNECTED         = HResultError(C.DXGI_ERROR_SESSION_DISCONNECTED)
	DXGI_ERROR_UNSUPPORTED                  = HResultError(C.DXGI_ERROR_UNSUPPORTED)
	DXGI_ERROR_WAIT_TIMEOUT                 = HResultError(C.DXGI_ERROR_WAIT_TIMEOUT)
	DXGI_ERROR_WAS_STILL_DRAWING            = HResultError(C.DXGI_ERROR_WAS_STILL_DRAWING)
)

func (e HResultError) Error() string {
	if code := HResultErrorCode[e]; code != "" {
		return code
	}
	return "unknown error"
}

var HResultErrorCode = map[HResultError]string{
	S_OK:           "S_OK",
	E_ABORT:        "E_ABORT",
	E_ACCESSDENIED: "E_ACCESSDENIED",
	E_FAIL:         "E_FAIL",
	E_HANDLE:       "E_HANDLE",
	E_INVALIDARG:   "E_INVALIDARG",
	E_NOINTERFACE:  "E_NOINTERFACE",
	E_NOTIMPL:      "E_NOTIMPL",
	E_OUTOFMEMORY:  "E_OUTOFMEMORY",
	E_POINTER:      "E_POINTER",
	E_UNEXPECTED:   "E_UNEXPECTED",

	DXGI_ERROR_ACCESS_DENIED: "DXGI_ERROR_ACCESS_DENIED",
	DXGI_ERROR_ACCESS_LOST:   "DXGI_ERROR_ACCESS_LOST",
	//DXGI_ERROR_ALREADY_EXISTS:               "DXGI_ERROR_ALREADY_EXISTS",
	DXGI_ERROR_CANNOT_PROTECT_CONTENT:       "DXGI_ERROR_CANNOT_PROTECT_CONTENT",
	DXGI_ERROR_DEVICE_HUNG:                  "DXGI_ERROR_DEVICE_HUNG",
	DXGI_ERROR_DEVICE_REMOVED:               "DXGI_ERROR_DEVICE_REMOVED",
	DXGI_ERROR_DEVICE_RESET:                 "DXGI_ERROR_DEVICE_RESET",
	DXGI_ERROR_DRIVER_INTERNAL_ERROR:        "DXGI_ERROR_DRIVER_INTERNAL_ERROR",
	DXGI_ERROR_FRAME_STATISTICS_DISJOINT:    "DXGI_ERROR_FRAME_STATISTICS_DISJOINT",
	DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE: "DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE",
	DXGI_ERROR_INVALID_CALL:                 "DXGI_ERROR_INVALID_CALL",
	DXGI_ERROR_MORE_DATA:                    "DXGI_ERROR_MORE_DATA",
	DXGI_ERROR_NAME_ALREADY_EXISTS:          "DXGI_ERROR_NAME_ALREADY_EXISTS",
	DXGI_ERROR_NONEXCLUSIVE:                 "DXGI_ERROR_NONEXCLUSIVE",
	DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:      "DXGI_ERROR_NOT_CURRENTLY_AVAILABLE",
	DXGI_ERROR_NOT_FOUND:                    "DXGI_ERROR_NOT_FOUND",
	DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED:   "DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED",
	DXGI_ERROR_REMOTE_OUTOFMEMORY:           "DXGI_ERROR_REMOTE_OUTOFMEMORY",
	DXGI_ERROR_RESTRICT_TO_OUTPUT_STALE:     "DXGI_ERROR_RESTRICT_TO_OUTPUT_STALE",
	DXGI_ERROR_SDK_COMPONENT_MISSING:        "DXGI_ERROR_SDK_COMPONENT_MISSING",
	DXGI_ERROR_SESSION_DISCONNECTED:         "DXGI_ERROR_SESSION_DISCONNECTED",
	DXGI_ERROR_UNSUPPORTED:                  "DXGI_ERROR_UNSUPPORTED",
	DXGI_ERROR_WAIT_TIMEOUT:                 "DXGI_ERROR_WAIT_TIMEOUT",
	DXGI_ERROR_WAS_STILL_DRAWING:            "DXGI_ERROR_WAS_STILL_DRAWING",
}
